#!/bin/bash
sudo steamos-readonly disable
sudo sed -i '173s/auth_admin_keep/yes/;253s/auth_admin_keep/yes/;181s/auth_admin_keep/yes/;265s/auth_admin_keep/yes/' /usr/share/polkit-1/actions/org.freedesktop.UDisks2.policy
sed -i '11,$d' /etc/fstab
# 获取UUID
UUID=$(sudo blkid -s UUID -o value /dev/nvme0n1p10)
# 检查UUID是否获取成功
if [ -z "$UUID" ]; then
    echo "无法获取UUID，请检查设备路径或设备是否已正确挂载"
    exit 1
fi
# 定义挂载点和fstab的其他字段
MOUNT_POINT="/run/media/deck/Game"
FS_TYPE="lowntfs-3g"
OPTIONS="nofail,uid=1000,gid=1000,rw,user,exec,umask=000"
DUMP="0"
PASS="0"
# 构建fstab条目
FSTAB_ENTRY="UUID=$UUID $MOUNT_POINT $FS_TYPE $OPTIONS $DUMP $PASS"
# 使用echo和sudo tee命令将条目追加到/etc/fstab文件中
echo "$FSTAB_ENTRY" | sudo tee -a /etc/fstab > /dev/null
# 检查是否成功写入
if [ $? -eq 0 ]; then
    echo "UUID已成功添加到/etc/fstab"
else
    echo "无法将UUID添加到/etc/fstab，请检查权限或文件系统状态"
    exit 1
fi
zenity --question --width=400 \
  --text="SteamDeck 超人制作
  已挂载成功！需要重启才能生效！, \
\n现在是否重启?"
if [ "$?" != 0 ]; then
  #NOTE: This code will never be reached due to "set -e", the system will already exit for us but just incase keep this
  echo "bye then! xxx"
  exit 0;
fi
reboot
echo "Done."
echo "Done."
